<?php

namespace App\Domain\LifeHealth\Controllers;

use App\Domain\LifeHealth\Requests\lifeStyleDrinkPost;
use App\Domain\LifeHealth\Requests\lifeStyleSleepingPost;
use App\Domain\LifeHealth\Requests\lifeStyleSmokingPost;
use App\Domain\LifeHealth\Requests\lifeStyleSportPost;
use App\Domain\LifeHealth\Services\LiftHealthService;
use App\Domain\LifeHealth\Requests\lifeFlavorPost;
use App\Http\Controllers\Controller;


class LifeHealthController extends Controller
{
    //是否吸烟
    public function lifeStyleSmoking(lifeStyleSmokingPost $request, LiftHealthService $healthRecordsService)
    {
        $param = $request->validated();
        if ($param['type'] == 0) {
            $result = $healthRecordsService->findBySmokeUid($param['memberUid']);
            return $this->success($result);
        } else {
            $result = $healthRecordsService->Smoke($param);
            return $this->success();
        }
    }


    //运动习惯
    public function lifeStyleSport(lifeStyleSportPost $request, LiftHealthService $healthRecordsService)
    {
        $param = $request->validated();
        if ($param['type'] == 0) {
            $result = $healthRecordsService->findBySportUid($param['memberUid']);
            return $this->success($result);
        } else {
            $result = $healthRecordsService->Sport($param);
            return $this->success();
        }
    }

    //睡眠时长
    public function lifeStyleSleeping(lifeStyleSleepingPost $request, LiftHealthService $healthRecordsService)
    {
        $param = $request->validated();
        if ($param['type'] == 0) {
            $result = $healthRecordsService->findBySleepUid($param['memberUid']);
            return $this->success($result);
        } else {
            $result = $healthRecordsService->Sleep($param);
            return $this->success();
        }
    }


    //是否饮酒
    public function lifeStyleDrinking(lifeStyleDrinkPost $request, LiftHealthService $healthRecordsService)
    {
        $param = $request->validated();
        if ($param['type'] == 0) {
            $result = $healthRecordsService->findByDrinkUid($param['memberUid']);
            return $this->success($result);
        } else {
            $result = $healthRecordsService->Drink($param);
            return $this->success();
        }
    }

    //口味偏好
    public function lifeStyleFlavor(lifeFlavorPost $request, LiftHealthService $healthRecordsService){
        $param = $request->validated();
        if ($param['type'] == 0) {
            $result = $healthRecordsService->findByFlavorUid($param['memberUid']);
            return $this->success($result);
        } else {
            $result = $healthRecordsService->Flavor($param);
            return $this->success($result);
        }
    }


}
